import { StoreOptions } from 'vuex'
import { MessageModelState } from '@/interfaces/vuex/message'

const messageModel: StoreOptions<MessageModelState> = {
  state: {
    useMessage: null,
    useNotification: null,
    useLoadingBar: null,
    dialog: null
  },
  mutations: {
    setUseMessage(state, value) {
      state.useMessage = value
    },
    setUseNotification(state, value) {
      state.useNotification = value
    },
    setUseLoadingBar(state, value) {
      state.useLoadingBar = value
    },
    startLoading(state) {
      state.useLoadingBar?.start()
    },
    endLoading(state) {
      state.useLoadingBar?.finish()
    },
    errorLoading(state) {
      state.useLoadingBar?.error()
    },
    setDialog(state, value) {
      state.dialog = value
    }
  },
  actions: {},
}

export default messageModel
